 /* To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jhave.client;

import javax.swing.*;
import java.util.*;
import java.awt.*;
import org.jdom.Element;

/**
 *
 * @author bosmak40
 */
public class Combobox_Element implements JHAVE_Element{

    JPanel returnedPanel;
    Vector components;
    GridLayout grid;
    Element child;
    JComboBox combobox;
    JPanel comboBoxPanel;

    Combobox_Element(Element child, JPanel returnedPanel, Vector components, GridLayout grid, JPanel comboBoxPanel){
        this.returnedPanel = returnedPanel;
        this.components = components;
        this.grid = grid;
        this.child = child;
        this.comboBoxPanel = comboBoxPanel;
    }


     /**
     * Adds Combobox element to panel and to components vector.
     *
     */
    public void addElementToPanel(){
        Iterator iter = child.getChildren().iterator();
        JHAVE_Combobox_Factory factory = new JHAVE_Combobox_Factory();
        JComboBox combobox = new JComboBox();
        combobox.setBackground(Color.white);
	

        while(iter.hasNext()){
	    
            Element newChild = (Element) iter.next();
            factory.get_JHAVE_Element(newChild, this.returnedPanel,this.components, this.grid, combobox, this.comboBoxPanel);
            this.returnedPanel = factory.returnPanel();
            this.components = factory.returnComponents();
            this.grid = factory.returnGrid();
            this.combobox = factory.returnComboBox();
	    this.comboBoxPanel = factory.returnComboBoxPanel();
        }
        this.components.add(combobox);
	
	
        this.comboBoxPanel.add(combobox);
	
    }

     /**
     * Returns returnedPanel.
     *
     *@return Returns the main JPanel.
     */
    public JPanel returnPanel(){
        return returnedPanel;
    }

     /**
     * Returns the components vector.
     *
     *@return Returns the components vector.
     */
    public Vector returnComponents(){
        return components;
    }

     /**
     * Returns GridLayout.
     *
     *@return Returns GridLayout.
     */
    public GridLayout returnGrid(){
        return grid;
    }

     /**
     * Returns ComboBox panel.
     *
     *@return Returns ComboBox JPanel.
     */
    public JPanel returnComboBoxPanel(){
        return comboBoxPanel;
    }



}